import os
import shutil

from ExcelUtils import write_to_excel, zip_folder
from config import *
from parse import group_by_day
from studentList import convert_data, create_student_list
from teachCal import create_teach_cal
from utils import generate_cal



if __name__ == '__main__':
    generate_cal(start_date_str, total_week)
    total_lessons = group_by_day()
    with open(output_excel_file,'w', encoding='utf-8') as f:
        for lesson in total_lessons:
            f.write(str(lesson) + '\n')
    write_to_excel(output_excel_file, excel_header, total_lessons)
    create_teach_cal(total_lessons)
    create_student_list(total_lessons)
    zip_folder(output_folder, output_folder+'.zip')
    shutil.rmtree(output_folder)

    print("Success, new file {} created!".format(output_excel_file))
    print("Download the file from: http://192.168.34.27:8000/" + os.path.basename(output_excel_file))